package com.example.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Commodit;
import com.example.util.QueryBean;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
import com.example.util.Pro;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author tyhxzy
 * @since 2023-11-03
 */
public interface CommoditMapper extends BaseMapper<Commodit> {

//    @Select("SELECT c.id, c.`name` AS 商品名称,c.`price` AS 价格,c.gprice AS 国标价格,\n" +
//            "        b.`address` AS 营业地址,\n" +
//            "        (SELECT doorhead FROM operate o WHERE o.id = c.`store` ) AS 门头照片\n" +
//            "        FROM commodit c,\n" +
//            "        business b\n" +
//            "\n" +
//            "        WHERE c.`id` = b.`id` and c.id=#{id}")
    @Select("SELECT b.companyname,b.address\n" +
            "FROM business b\n" +
            "WHERE id=#{id}")
    Map findByid(Integer id);

//    @Select("SELECT c.id, c.`name` AS 商品名称,c.`price` AS 价格,c.gprice AS 国标价格,\n" +
//            "        b.`address` AS 营业地址,\n" +
//            "        (SELECT doorhead FROM operate o WHERE o.id = c.`store` ) AS 门头照片\n" +
//            "        FROM commodit c,\n" +
//            "        business b\n" +
//            "\n" +
//            "        WHERE c.`id` = b.`id`")
    @Select("SELECT * \n" +
            "FROM business")
    List<Map> findAll();

    List<Pro> findCom(Commodit commodit);
    int updateStatus1(Integer id);
    int updateStatus2(Integer id);
    @SelectKey(statement = "select last_insert_id()" ,keyColumn = "id",keyProperty = "id",before = false,resultType = Integer.class)
    @Insert("INSERT INTO commodit(NAME,price,gprice,info,store,status) VALUE (#{name},#{price},#{gprice},#{info},#{store},#{status})")
    int addCommodit(Commodit commodit);

    List<Map> findalls(Integer id);
}
